package com.pt.manage.controller;
import com.pt.common.core.domain.AjaxResult;
import com.pt.common.utils.WordUtils;
import com.pt.manage.domain.ApiResponse;
import com.pt.manage.service.impl.DeepSeekService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import static com.pt.common.core.domain.AjaxResult.success;

@RestController
@RequestMapping("/api")
public class FileController {
    @Value("${ruoyi.filePath}")
    private String sysFilePath;

    private final DeepSeekService deepSeekService;
    public FileController(DeepSeekService deepSeekService) {
        this.deepSeekService = deepSeekService;
    }

    @PostMapping("/upload")
    public AjaxResult handleFileUpload(@RequestBody String wordUrl) {

        try {
            System.out.println(wordUrl);
            String text = WordUtils.convertWordToText(sysFilePath + wordUrl);
            return success(deepSeekService.askDeepSeek(text));


//            ApiResponse ar = new ApiResponse("2","1");
//            return success(ar);
        } catch (Exception e) {
            throw new RuntimeException("文件处理失败: " + e.getMessage());
        }
    }
}